package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-05-21
 * Time: 18:28
 */
public class computer {
    public void open(){
        System.out.println("打开电脑");
    }
    public void close(){
        System.out.println("关闭电脑");
    }

    public void useUsbDevice(USB usb){
        usb.openDevice();
        if(usb instanceof keyboard){
           keyboard keyboard = (keyboard)usb;
           keyboard.click();
        }else{
            mouse mouse = (mouse)usb;
            mouse.apply();
        }
        usb.closeDevice();
    }
}
